<script src="<?php print $url?>js/jquery.ui.datepicker.js"></script>
<script src="<?php print $url?>js/jquery.ui.core.js"></script>
<script src="<?php print $url?>js/jquery.ui.autocomplete.js"></script>
<script src="<?php print $url?>js/jquery.price_format.1.8.min.js"></script>
<div id="main-content">
  <div class="container-fluid">
    <ul class="breadcrumb">
      <li><a href="<?php print site_url("keuangan-yayasan/journal")?>"><?php print lang('frm_journal')?></a><span class="divider">»</span></li>
      <li><a href="<?php print site_url("keuangan-yayasan/journal-log/".$id_keuangan_yayasan_journal)?>"><?php print lang('frm_journal_transaksi')?></a><span class="divider">»</span></li>
      <li><a href="<?php print site_url("keuangan-yayasan/all-buku-besar/".$id_keuangan_yayasan_journal)?>"><?php print lang('frm_buku_besar')?></a><span class="divider">»</span></li>
      <li><a href="<?php print site_url("keuangan-yayasan/neraca/".$id_keuangan_yayasan_journal)?>"><?php print lang('frm_neraca')?></a><span class="divider">»</span></li>
      <li><a href="<?php print site_url("keuangan-yayasan/neraca-penyesuaian/".$id_keuangan_yayasan_journal)?>"><?php print lang('frm_neraca_penyesuaian')?></a><span class="divider">»</span></li>
      <li><a href="<?php print site_url("keuangan-yayasan/journal-log-penyesuaian/".$id_keuangan_yayasan_journal)?>"><?php print lang('frm_journal_penyesuaian')?></a><span class="divider">»</span></li>
      <li class="active"><?php print $title?></li>
    </ul>
    <div class="row-fluid">
			<div class="span12 ">
				<div class="widget-block">
          <?php
          if($status == '2'){
          ?>
          <div class="alert alert-error fade in">
            <button data-dismiss="alert" class="close" type="button">×</button>
            <strong><?php print urldecode($pesan)?></strong>
          </div>
          <?php
          }
          if($status == '1'){
          ?>
          <div class="alert alert-success fade in">
            <button data-dismiss="alert" class="close" type="button">×</button>
            <strong><?php print urldecode($pesan)?></strong>
          </div>
          <?php
          }
          ?>
					<div class="widget-head">
						<h5><?php print $title?></h5>
					</div>
					<div class="widget-content">
						<div class="widget-box">
							<?php print $this->form_eksternal->form_open("", 'class="form-horizontal well"', array("id_detail" =>  $data[0]->id_frm_journal_log))?>
									<!--<legend>User Form</legend>-->
                  <fieldset>
										<div class="control-group">
											<label class="control-label">Tanggal</label>
											<div class="controls">
                        <?php 
                        if(!$data[0]->tanggal)
                          $data[0]->tanggal = date("Y-m-d");
                        
                        print $this->form_eksternal->form_date("tanggal", $data[0]->tanggal, "tanggal")?>
											</div>
										</div>
                    <div class="control-group">
											<label class="control-label">No Transaksi</label>
											<div class="controls">
                        <?php print $this->form_eksternal->form_input('notransaksi', $data[0]->notransaksi, 'class="input-xlarge"')?>
											</div>
										</div>
										<div class="control-group">
											<label class="control-label"><b>Debit</b></label>
											<div class="controls">
                        <?php print $this->form_eksternal->form_addrow_autocomplate_input(
                                "debit_account[]", 
                                "debit_price[]", 
                                "da[]", 
                                "debit_1", 
                                site_url("frm/accounting/addrow-account/debit_account/da/debit_price/debit"), 
                                "debit_table", 
                                "add_debit", 
                                "debit_nomor", 
                                $tr['debit'], 
                                "debit", 
                                site_url("frm/accounting/auto-account"), 
                                $string['debit'], 
                                $price_value['debit'], 
                                $value_id['debit'], 
                                "onblur='jumlah_debit()'", 
                                $delete = true, 
                                "debit_update[]", 
                                $id_update['debit'])?>
                        <input type="text" disabled id="debit_jumlah" value="" />
                        <input type="text" style="display: none" id="debit_nomor" value="1" />
											</div>
										</div>
										<div class="control-group">
											<label class="control-label"><b>Kredit</b></label>
											<div class="controls">
                        <?php print $this->form_eksternal->form_addrow_autocomplate_input("kredit_account[]", "kredit_price[]", "ka[]", "kredit_1", 
                        site_url("frm/accounting/addrow-account/kredit_account/ka/kredit_price/kredit"), "kredit_table", "add_kredit", "kredit_nomor", 
                        $tr['kredit'], "kredit", site_url("frm/accounting/auto-account"), $string['kredit'], $price_value['kredit'], 
                        $value_id['kredit'], "onblur='jumlah_kredit()'", $delete = true, "kredit_update[]", $id_update['kredit'])?>
                        <input type="text" disabled id="kredit_jumlah" value="" />
                        <input type="text" style="display: none" id="kredit_nomor" value="1" />
											</div>
										</div>
                    <div class="control-group">
											<label class="control-label">Note</label>
											<div class="controls">
                        <?php print $this->form_eksternal->form_textarea('note', $data[0]->note, 'class="input-xlarge" rows="3"')?>
											</div>
										</div>
									</fieldset>
								<div class="form-actions">
									<button type="submit" class="btn btn-info">Save changes</button>
                  <a href="<?php print site_url("keuangan-yayasan/add-journal-transaksi-penyesuaian/".$id_keuangan_yayasan_journal)?>" class="btn btn-warning" >Cancel</a>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
    </div>
  </div>
</div>
<script>
  function add_row_tambahan(table,url,act,param){
    var no = parseInt($('#'+param).val());
    $('#'+param).val(no+1);
    $.post(url,{no:$('#'+param).val(),action:act},function(data){
        $(data).clone(true).insertBefore("#"+table+" #"+act);
    });
  }
  function del_row_tambahan(tr){
    $("#"+tr).remove();
  }
  function jumlah_debit(){
    var jml = $('#debit_nomor').val() * 1;
    var total = 0;
    for(j = 1; j <= jml ; j++){
      var rupiah = $('#debit_'+j+'set').val();
      if(typeof rupiah != 'undefined'){
        var nilai_jadi = stringtonilai(rupiah);
      }
      else{
        var nilai_jadi = 0;
      }
      total = total + nilai_jadi;
    }
    $("#debit_jumlah").val("Rp " + get_dot(total));
  }
  function jumlah_kredit(){
    var jml = $('#kredit_nomor').val() * 1;
    var total = 0;
    for(j = 1; j <= jml ; j++){
      var rupiah = $('#kredit_'+j+'set').val();
      if(typeof rupiah != 'undefined'){
        var nilai_jadi = stringtonilai(rupiah);
      }
      else{
        var nilai_jadi = 0;
      }
      total = total + nilai_jadi;
    }
    $("#kredit_jumlah").val("Rp " + get_dot(total));
  }
  function stringtonilai(str){
//    alert(str);
    var nilai_temp = str.replace("Rp ", "");
    nilai_temp = nilai_temp.replace(".", "");
    var string_hasil = "";
    for(i = 0 ; i < nilai_temp.length ; i++){
      if(nilai_temp[i] != "."){
        if(nilai_temp[i] == ",")
          string_hasil = string_hasil + ".";
        else
          string_hasil = string_hasil + nilai_temp[i];
      }
    }
    var nilai = string_hasil * 1;
    return nilai;
  }
  function get_dot(asli, koma){
    asli = asli.toFixed(0);
    asli = asli.toString();
    var asli_temp = asli.split(".");
    var string = asli_temp[0];
    var string_hasil = "";
    
    var tanda = 0;
    var kl = string.length % 3;
    if(kl == 0)
      kl = 3;
    for(i = 0 ; i < string.length ; i++){
      if(tanda == 3 || i == kl){
        string_hasil = string_hasil + ".";
        tanda = 0;
        kl = 0;
      }
      string_hasil = string_hasil + string[i];
      tanda++;
    }
//    if(koma == true){
      if(!asli_temp[1])
        asli_temp[1] = '';
      
      return string_hasil;
//    }
//    else
//      return string_hasil;
  }
</script>